USE [NANS21V]
GO

/****** オブジェクト: Scalar Function [dbo].[JYUNI] スクリプト日付: 2014/05/30 10:03:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Jyuni]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[Jyuni]
GO

CREATE FUNCTION [dbo].[Jyuni]
(
	@JYUNI int,
	@OPENFLG int
)
RETURNS VARCHAR(10)
AS
BEGIN
	DECLARE @return varchar(10)
	IF(@OPENFLG = 1)
		SET @return = 'OP'
	ELSE IF(@JYUNI != 0)
		SET @return = @JYUNI
	ELSE 
		SET @return = ''
	

	RETURN @return
END